home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2005 March
/
CMCD0305.ISO
/
Software
/
Shareware
/
Utilitare
/
emu
/
Emu8086_Setup_307c.exe
/
{app}
/
Samples
/
matrix.asm
< prev
next >
Wrap
Assembly Source File
|
2002-11-28
|
923b
|
74 lines
; Matrix transpose sample
; (reverse rows with columns).
#make_COM#
ORG 100h
jmp start
; To view matrix select
; "Variables" from "View"
; menu of the emulator
; and set [Elements] property
; to "3" for these items:
; MATRIX
; ROW1
; ROW2
matrix_size EQU 3
; ----- matrix ------
matrix db 1,2,3
row1 db 4,5,6
row2 db 7,8,9
;--------------------
i dw ?
j dw ?
start:
mov i, 0
next_i:
; j = i + 1
mov cx, i
inc cx
mov j, cx
next_j:
MOV SI, i
MOV BX, j
MOV AL, matrix_size
MOV CX, SI
MUL CL
MOV SI, AX
MOV DL, matrix[SI][BX]
MOV SI, i
MOV AL, matrix_size
MUL BL
MOV BX, AX
XCHG matrix[BX][SI], DL
MOV BX, j
MOV AL, matrix_size
MOV CX, SI
MUL CL
MOV SI, AX
MOV matrix[SI][BX], DL
INC j
CMP j, matrix_size
JB next_j
INC i
CMP i, matrix_size/2
JBE next_i
ret
end